<?php
/********************************************************
** Copyright 2010-2013. Todos los derechos reservados. **
** Desarrollado y Gestionado por:					   **
** Sugey Quintero (Analista)						   **
** José G. De Freitas (Programador)					   **
** Klaudia Uribe (Diseñadora Web)					   **
** Cesar Isturiz (Diseñador Web)					   **
**				S E A  v1.0							   **
*********************************************************/

session_start();
include("conexion2.php");

	if (isset($_SESSION['name']) and isset($_SESSION['tiempo'])) {
        include("Tiempo.php");
		date_default_timezone_set('America/Caracas'); setlocale(LC_TIME, 'spanish');
		$usuario = $_SESSION['name'];
		$fecha = date("Y-m-d H:i:s");
		$auditoria = mysql_query("INSERT INTO auditoria SELECT '$usuario', '$fecha' , 'Registro notas estudiantes liceo' ");

    }else {
		echo "<script>alert('Debe ingresar al sistema primero');</script>";
		echo "<script>document.location.href='index.php';</script>";
	}
include("conexion.php");
$periodo = $_GET['periodo'];
$lapso=$_GET['lapso'];
	if ($lapso == '1er Lapso'){ $a='I'; }
	else if ($lapso == '2do Lapso'){ $a='II'; }
	else if ($lapso == '3er Lapso'){ $a='III'; }
$materia=$_GET['materia'];
$grado=$_GET['grado'];
$seccion=$_GET['seccion'];
	if ($lapso){
		$resultado=mysql_query("SELECT alumno.CI_a, alumno.nombre_a, alumno.apellido_a FROM alumno INNER JOIN inscripcion ON alumno.CI_a=inscripcion.cedula_a WHERE inscripcion.periodo='$periodo' AND inscripcion.grado='$grado' AND inscripcion.seccion='$seccion' order by alumno.CI_a");
		$prof=mysql_query("select CI_p, nombre_p, apellido_p from profesor where grado='$grado' and seccion='$seccion'");
	}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Registro De Evaluaciones</title>
<link rel="shortcut icon" type="image/x-icon" href="../favicon.ico">
<link href="style.css" rel="stylesheet" type="text/css" />
<!-- calendario-->
<link rel="stylesheet" type="text/css" href="src/css/jscal2.css" />
<link rel="stylesheet" type="text/css" href="src/css/border-radius.css" />
<link rel="stylesheet" type="text/css" href="src/css/steel/steel.css" />
<script type="text/javascript" src="src/js/jscal2.js"></script>
<script type="text/javascript" src="src/js/lang/es.js"></script>
<!-- fin calendario-->
<!-- botones-->
<link type="text/css" href="js/css/smoothness/jquery-ui-1.8.16.custom.css" rel="Stylesheet" />      
<script type="text/javascript" src="js/jquery-1.6.2.min.js"></script>
<script type="text/javascript" src="js/jquery-ui-1.8.16.custom.min.js"></script>
<script src="js/valida_ar.js" type="text/javascript"></script>
<script src="js/prototype.js" type="text/javascript"></script>
<script language="JavaScript" src="js/valida_p.js"></script>
<script>
var j$ = jQuery.noConflict();
j$(document).ready(function(){
j$(".button").button();
});

j$(function(){
	j$('#menu li a').click(function(event){
		var elem = j$(this).next();
		if(elem.is('ul')){
			event.preventDefault();
			j$('#menu ul:visible').not(elem).slideUp();
			elem.slideToggle();
		}
	});
});

function SeleccionarMaterias(mat) {
	var o;
	document.forms.materias.grado.disabled = true;
		<?php $materias = mysql_query("SELECT * FROM materia");
				while($mat = mysql_fetch_array($materias)) { ?>
	if(mat == "<?php echo $mat[2]; ?>") {
		o = document.createElement("OPTION");
		o.text="<?php echo $mat[1]; ?>";
		o.value="<?php echo $mat[1]; ?>";
		document.forms.materias.materia.options.add(o);
	}
<?php } ?>
			document.forms.materias.materia.disabled = false;
	}
function ComponerMaterias(mat) {
	document.forms.materias.grado.disabled = true;
		for(var i=document.forms.materias.materia.options.length-1; i>0; i--){
			document.forms.materias.materia.remove(i);
		}
	SeleccionarMaterias(mat);
	document.forms.materias.grado.disabled = false;
}

function habilitar(nota,nro){
	if(nota == 1){
		document.getElementById('nota'+nro).style.display="inline";
		document.getElementById('ImgSi'+nro).style.display="none";
	}else if(nota == 0){
		document.getElementById('nota'+nro).style.display="inline";
		document.getElementById('ImgNo'+nro).style.display="none";
	}
}
</script>
<!-- fin botones-->
</head>

<body>
<div id="wrap">
<div id="header">
<div id="hora">
<?php include("Hora.php"); ?>
</div>
<div id="topnav">
	<?php include("MenuSuperior.php"); ?>
</div>
</div>
<div id="content">
<div id="left">
<div class="post">
<div class="post_h">

</div>

<div class="postcontent">

<blockquote><h2 align="center">EVALUACI&Oacute;N</h2></blockquote>
		<fieldset>
		<legend align=left><b><font size=2>BUSCADOR</font></b></legend>
			<form action=plani_regis_eval.php method=GET name=materias>
			<table width=100% cellspacing=3 cellpadding=0 border=0>
				
					<tr>
						<td align=center><select name=grado onChange=ComponerMaterias(this.options[this.selectedIndex].value)>
											<option>Grado</option>
											<option value='1er' <?php if ($grado=='1er'){ echo "Selected"; } ?>>1er A&ntilde;o</option>
											<option value='2do' <?php if ($grado=='2do'){ echo "Selected"; } ?>>2do A&ntilde;o</option>
											<option value='3er' <?php if ($grado=='3er'){ echo "Selected"; } ?>>3er A&ntilde;o</option></select>
									<select name=seccion><option>Secci&oacute;n</option>
											<option value='A' <?php if ($seccion=='A'){ echo "Selected"; } ?>>A</option>
											<option value='B' <?php if ($seccion=='B'){ echo "Selected"; } ?>>B</option></select>
									<select name=materia><option>Materia</option></select>
									<select name=lapso><option>Lapso</option>
											<option value='1er Lapso' <?php if ($lapso=='1er Lapso'){ echo "Selected"; } ?>>1er Lapso</option>
											<option value='2do Lapso' <?php if ($lapso=='2do Lapso'){ echo "Selected"; } ?>>2do Lapso</option>
											<option value='3er Lapso' <?php if ($lapso=='3er Lapso'){ echo "Selected"; } ?>>3er Lapso</option></select></td>
									<input type=hidden name='periodo' value='<?php if(date(m)>=8){ $anio=date(Y); $anio2=$anio+1; echo "$anio - $anio2"; } else{ $anio=date(Y)-1; $anio2=$anio+1; echo "$anio - $anio2"; } ?>'>
						<td><input class=button type=submit value=Buscar>
					</tr>
				</form>
			</table>
		</fieldset>

<div class="post">
<span></span></div>

<?php if($prof){
	echo "
		<fieldset>
		<legend align=left><b><font size=2>MATERIA: ".strtoupper($materia)."</font></b></legend>
			<form action=plani_eval.php method=post name=lapsos>
			<table width=100% cellspacing=3 cellpadding=0 border=0>
				<tr><td><br></td></tr>
				<tr>";
			while($row=mysql_fetch_array($prof)){
				echo "<td><b>CEDULA:</b> $row[0]</td>
					<td><b>PROFESOR GU&Iacute;A:</b> ".strtoupper($row[1].' '.$row[2])."</td>
					</tr><tr><td><b>A&Ntilde;O:</b> $grado A&ntilde;o</td>
					<td><b>SECCION:</b> $seccion</td>";
			}
		echo "</tr>
		</table>
		<table border=0 width=100% cellpadding=0 cellspacing=5>
			<tr><td><br></td></tr>
			<tr>
				<th colspan=4><font size=2>E S T U D I A N T E S</font></th><th><font size=2>LAPSO $a</font></th>
			</tr>
			<tr>
				<th>Nro</th>
				<th>C&eacute;dula</th>
				<th>Nombres</th>
				<th>Apellidos</th>
				<th>Nota</th>
			</tr>";
			$a = 1;
				while ($row=mysql_fetch_array($resultado)){
					if($lapso == '1er Lapso'){
						$buscar = mysql_fetch_array(mysql_query("select nota1 from alumno_has_materia where ano_escolar='$periodo' and Alumno_CI_a='$row[0]' and Materia_Cod_m=(select Cod_m from materia where nombre_m='$materia' and ano_m='$grado')"));
							//if($nota == 0){
								//$buscar == '';
							//}
					}else if($lapso == '2do Lapso'){
						$buscar = mysql_fetch_array(mysql_query("select nota2 from alumno_has_materia where ano_escolar='$periodo' and Alumno_CI_a='$row[0]' and Materia_Cod_m=(select Cod_m from materia where nombre_m='$materia' and ano_m='$grado')"));
							//if($nota == 0){
								//$buscar == '';
							//}
					}else if($lapso == '3er Lapso'){
						$buscar = mysql_fetch_array(mysql_query("select nota3 from alumno_has_materia where ano_escolar='$periodo' and Alumno_CI_a='$row[0]' and Materia_Cod_m=(select Cod_m from materia where nombre_m='$materia' and ano_m='$grado')"));
							//if($nota == 0){
								//$buscar == '';
							//}
					}
					echo "<tr>";
					echo "<td align=center>$a</td>";
					echo "<td align=center><a href='datos_gen_a.php?cedula=$row[0]' title='Click aqui para visualizar o actualizar los datos del estudiante'>$row[0]</a></td>";
					echo "<td align=center>$row[1]</td>";
					echo "<td align=center>$row[2]</td>";
				if($buscar[0] > 0){
					echo "<td align=center><img src='images/check.jpg'id=ImgSi$a title='Nota ingresada, presione aqui para visualizarla.' onclick='habilitar(1,$a)'><input type=text style='display: none;' id=nota$a size=1 maxLength=2 name=nota[] value='$buscar[0]'></td></tr>";
				}else{
					echo "<td align=center><img src='images/alerta.jpg' id=ImgNo$a width=20 height=20 title='Falta ingresar nota, presione aqui para ingresarla.' onclick='habilitar(0,$a)'><input type=text style='display: none;' id=nota$a size=1 maxLength=2 name=nota[] value='$buscar[0]'></td></tr>";
				}
					echo "<input type=hidden value='$lapso' name=lapso>";
					echo "<input type=hidden value='$row[0]' name=ced_a[]>";
			$a++;	}
			echo "
			<input type=hidden name=grado value='$grado'>
			<input type=hidden name=materia value='$materia'>
		
		</table>
		
	</fieldset>";
} ?>

<div class="post">
<span></span></div>

<?php if($resultado){
	echo "<div id=botonera align=center>
		<input class=button type=submit value=Guardar onclick=valida();>
		<input class=button type=button value=Cancelar onClick=location='index.php'>
	</div>";
	echo "</form>";
} ?>

</div>
<div class="post_b">
<span></span></div>
</div>


</div>

<div class="post">
<div class="post_h">

</div>


</div>

<?php include("Menu.php"); ?>

<div class="clear"></div>
</div>
<div id="pagebottom"></div>

<div id="footer">
<P>&reg; Derechos Reservados @ CopyRight. 2011-2012</P>
<p>Programadores: Quintero E, Isturiz C, Uribe C, De Freitas J.</p>
</div>
</div>
</body>
</html>
